// Program Loader for PCMod (CLIENTSIDE)

ProgramList = {}

PROG = {}

local cnt = 0
/*
local prog_folders = file.FindDir ("../lua/programs/*")

for _,folder in pairs (prog_folders) do
	// Add to our count
	cnt = cnt + 1
	
	// Redefine the program
	PROG = {}
	
	PROG.CodeName = folder
	PROG.Path = "programs/" .. PROG.CodeName .. "/"
	
	// Include the file
	include( PROG.Path .. "cl_init.lua" )
	
	// Validate the required fields
	if (!PROG.PName) then PROG.PName = "Unknown" end
	if (!PROG.Name) then PROG.Name = "Unknown" end
	if (!PROG.Author) then PROG.Author = "Unknown" end
	if (!PROG.Exists) then PROG.Exists = true end
	
	// Insert the program
	ProgramList[ PROG.PName ] = PROG
	
	// Notify the console
	Msg( "PCMod -> Program " .. PROG.PName .. " loaded!\n" )
end

Msg( "PCMod -> " .. tostring( cnt ) .. " programs loaded!\n" )

*/

for k, v in pairs (file.FindInLua( "programs/cl_p_*")) do
	// Add to our count
	cnt = cnt + 1
	
	// Redefine the program
	PROG = {}
	
	//PROG.CodeName = folder
	//PROG.Path = "programs/" .. PROG.CodeName .. "/"
	
	// Include the file
	include( "programs/" .. v )
	
	// Validate the required fields
	if (!PROG.PName) then PROG.PName = "Unknown" end
	if (!PROG.Name) then PROG.Name = "Unknown" end
	if (!PROG.Author) then PROG.Author = "Unknown" end
	if (!PROG.Exists) then PROG.Exists = true end
	
	// Add our own functions to it
	function PROG:SetEnableTools( enabled )
		local ico = PCMod.ToolsIcon
		if (!ico) then return end
		ico:SetVisible( enabled )
	end
	
	table.Merge( PROG, PCLIB )
	
	// Insert the program
	ProgramList[ PROG.PName ] = PROG
	
	// Notify the console
	Msg( "PCMod -> Program " .. PROG.PName .. " loaded!\n" )
end

Msg( "PCMod -> " .. tostring( cnt ) .. " programs loaded!\n" )